home *** CD-ROM | disk | FTP | other *** search
/ Palm Pilot Collection / Palm Pilot Collection (Explore the World of Software) (1998).iso / apps / mathpad.exe / MPDB.H < prev    next >
C/C++ Source or Header  |  1997-09-28  |  4KB  |  135 lines

  1. /* mpdb.h: C include file describing common elements used by both
  2.  * MpExport and MpImport.
  3.  *
  4.  * Written in plain vanilla ANSI standard C; should compile pretty easily
  5.  * with any regular C compiler.  Released to the public domain.
  6.  *
  7.  * Version 1.0, 28 Sep 1997, Rick Huebner
  8.  */
  9.  
  10. /* Uncomment only one of the following definitions, depending
  11.  * on the kind of machine you're compiling this program for.
  12.  * Define BIG_ENDIAN if using a system which stores integers
  13.  * starting with the most significant byte (Motorola, etc.), or
  14.  * define LITTLE_ENDIAN if using a system which stores integers
  15.  * starting with the least significant byte (Intel, etc.)
  16.  */
  17. /* #define BIG_ENDIAN */
  18. #define LITTLE_ENDIAN
  19.  
  20. #ifdef LITTLE_ENDIAN
  21.    #ifdef BIG_ENDIAN
  22.       ERROR: Select only one "endian" definition
  23.    #else
  24.       void SwapWord(void *p);
  25.       void SwapDWord(void *p);
  26.    #endif
  27. #else
  28.    #ifndef BIG_ENDIAN
  29.       ERROR: You must select an "endian" definition
  30.    #else
  31.       #define SwapWord(NoOp)
  32.       #define SwapDWord(NoOp)
  33.    #endif
  34. #endif
  35.  
  36. /* Byte offset of a member variable in a structure; just in
  37.  * case it's not defined in stddef.h like it should be
  38.  */
  39. #ifndef offsetof
  40.    #define offsetof(s,m) (size_t)( (char *)&(((s *)0)->m) - (char *)0 )
  41. #endif
  42.  
  43. #ifndef TRUE
  44.    #define TRUE  1
  45.    #define FALSE 0
  46. #endif
  47.  
  48. /* Shared constants */
  49. #define MathPadCreator   "MthP"
  50. #define MathPadType      "Data"
  51. #define MathPadVersion   1
  52. #define CategoryLine     "Category = \"%s\"; Secret = %d\n"
  53. #define CatTestLength    12
  54. #define PlacesLine       "Places = %d; StripZeros = %d\n"
  55. #define PlacesTestLength 9
  56. #define SeparatorLine    "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
  57. #define SepTestLength    27
  58. #define PilotEOL         0x0A
  59.  
  60. /* Basic data types used by MathPad and the system structs */
  61. typedef char Char;
  62. typedef unsigned char Byte;
  63. typedef Byte Boolean;
  64. typedef unsigned short int Word;
  65. typedef unsigned long int DWord;
  66. typedef DWord LocalID;
  67.  
  68.  
  69.  
  70. /* The following declarations are excerpted from the PalmPilot system
  71.  * include files DataMgr.h, DataPrv.h, and Category.h to allow compilation
  72.  * of this program without requiring the full set of PalmPilot headers.
  73.  *
  74.  * NOTE: When a PalmPilot database is backed up to the PC's hard drive,
  75.  * the LocalID entries in the structs below are used to store the file
  76.  * offsets where each memory chunk was written.  When the database is
  77.  * re-installed on the PalmPilot, HotSync will change the LocalIDs to
  78.  * show where each memory chunk is stored in the PalmPilot's memory.
  79.  */
  80. #define dmDBNameLength        32
  81. #define dmCategoryLength      16
  82. #define dmRecNumCategories    16
  83. #define dmRecAttrCategoryMask 0x0F
  84. #define dmRecAttrSecret       0x10
  85. #define dmUnfiledCategory     0
  86.  
  87. typedef struct {
  88.    LocalID localChunkID;
  89.    Byte    attributes;
  90.    Byte    uniqueID[3];
  91. } RecordEntryType, *RecordEntryPtr;
  92.  
  93. typedef struct {
  94.    LocalID nextRecordListID;
  95.    Word    numRecords;
  96.    Word    firstEntry;
  97. } RecordListType, *RecordListPtr;
  98.  
  99. typedef struct {
  100.    Byte    name[dmDBNameLength];
  101.    Word    attributes;
  102.    Word    version;
  103.    DWord   creationDate;
  104.    DWord   modificationDate;
  105.    DWord   lastBackupDate;
  106.    DWord   modificationNumber;
  107.    LocalID appInfoID;
  108.    LocalID sortInfoID;
  109.    DWord   type;
  110.    DWord   creator;
  111.    DWord   uniqueIDSeed;
  112.    RecordListType recordList;
  113. } DatabaseHdrType, *DatabaseHdrPtr;
  114.  
  115. typedef struct {
  116.    Word renamedCategories;
  117.    Char categoryLabels[dmRecNumCategories][dmCategoryLength];
  118.    Byte categoryUniqIDs[dmRecNumCategories];
  119.    Byte lastUniqID;
  120. } AppInfoType, *AppInfoPtr;
  121.  
  122.  
  123.  
  124. /* MathPad structures */
  125. typedef struct {
  126.    AppInfoType appinfo;
  127.    Byte MathPadData[34];
  128. } MathPadAppInfoType;
  129.  
  130. typedef struct {
  131.    Byte places;
  132.    Boolean stripzeros;
  133.    char text[1];
  134. } MathPadItemType;
  135.